﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Configuration;
using System.Data;
using System.Text;
using System.IO;

namespace IHISCETeim.Web.MachineSys
{
    /// <summary>
    /// sysAjaxDone 的摘要说明
    /// </summary>
    public class sysAjaxDone : IHttpHandler
    {
        public enum ajaxmethod
        {
            deletemenu,
            deleterole,
            deleteuser,
            disableduser,
            enableduser,
            deletedaily,
            deletejob,
            deleteocompletingcheck,
            getotallyproject,
            deleteoinspection,
            deleteoproject,
            deleteuwarrantycard,
            deleteureturnvisit,
            getuwarrantycardbyserialnumbert,
            deleteu4008record,
            sendsingbirthday,
            personalitysendbirthday,
            getutallysurvey,
            deleteuqualityquestionnaire,
            sendagentsmsgroup,
            sendcustomersmsgroup,
            deleteuagentmacstocklist,
            deleteuagentmacstockdetail,
            deleteumackeep,
            personalitysendkeepalarm,
            sendsingkeepalarm,
            /// <summary>
            /// 同步发货记录,从SAP
            /// </summary>
            syncuclaimdemage,
            deleteuclaimdemagelist,
            
            /// <summary>
            /// 删除物料管制表
            /// </summary>
            deleteocontrolticket,
           
            /// <summary>
            /// 删除供应商提供件
            /// </summary>
            deleteusupplerpart,
            /// <summary>
            /// 更改我的个性化设置
            /// </summary>
            changemysetting,
            /// <summary>
            /// 删除保养提醒短信
            /// </summary>
            deletekeepalarm,
            /// <summary>
            /// 列新供应商索赔明细
            /// </summary>
            uclaimdemagecontrolupdatesupplerdetail,
            /// <summary>
            /// 更新索赔结算明细
            /// </summary>
            uclaimdemagecontrolupdatefinaldetail,
            /// <summary>
            /// 删除索赔管控
            /// </summary>
            deleteuclaimdemagecontrol,
            
            /// <summary>
            /// 删除制程检验记录表
            /// </summary>
            deleteomailline,           
            /// <summary>
            /// 删除模具分摊
            /// </summary>
            deleteptoolingcharge,
            /// <summary>
            /// 删除市验证项
            /// </summary>
            deleteomarketqualification,
            /// <summary>
            /// 删除市场部物料主数据
            /// </summary>
            deletemmarketitem,
            /// <summary>
            /// 删除证件
            /// </summary>
            deletespapersremind,
            /// <summary>
            /// 删除经销商地址
            /// </summary>
            deletemagentaddress,
            /// <summary>
            /// 删除考勤
            /// </summary>
            deletexzkaoqin,
            /// <summary>
            /// 删除DWF图纸分类目录
            /// </summary>
            deletejsdwffolder,
            /// <summary>
            /// 删除图纸文件
            /// </summary>
            deletejsdwf,
            /// <summary>
            /// 删除流程节点
            /// </summary>
            deletejsdwfflowconfig,
            /// <summary>
            /// 禁用审批节点
            /// </summary>
            disabledjsdwfflowconfig,
            /// <summary>
            /// 起用审批节点
            /// </summary>
            enabledjsdwfflowconfig,
            /// <summary>
            /// 检查机号与发动机号一致性
            /// </summary>
            checkenginenumber,
              /// <summary>
            /// 完成检查书，各号码唯 一性检查
            /// </summary>
            ocompletingcheckcheckuniquenum,
            /// <summary>
            /// 删除风险融资进度表
            /// </summary>
            deletefxfinancelease,
            /// <summary>
            /// 删除区域经销商
            /// </summary>
            deletesareamanageragent,
            /// <summary>
            /// 删除应收帐款数据
            /// </summary>
            deleteftradereceivables,
             /// <summary>
            /// 更改返还利息状态(应收帐款)
            /// </summary>
            updatefanhuanlixistate,
            /// <summary>
            /// 删除应收帐款-->维保费
            /// </summary>
            deleteftradeupkeep,
             /// <summary>
            /// 删除应收帐款发票
            /// </summary>
            deleteftradeinvoice,
            /// <summary>
            /// 取消收款记录
            /// </summary>
            deleteftradecathering,
            /// <summary>
            /// 删除收款记录
            /// </summary>
            deleteftradecatheringall,
            /// <summary>
            /// 删除不适合口处理票
            /// </summary>
            deleteounsuitableprod,
            /// <summary>
            /// 应收帐款_检测机号
            /// </summary>
            ftradereceivablescheckjihao,
            /// <summary>
            /// 删除岗位培训清单内容
            /// </summary>
            deletexztrain,
            /// <summary>
            /// 删除出货进度
            /// </summary>
            deleteyyshopment,
            /// <summary>
            /// 删除保养件赠送记录
            /// </summary>
            deletembaoyang,
            /// <summary>
            /// 删除专案件
            /// </summary>
            deleteuspecialcase,
            /// <summary>
            /// 删除专案件明细
            /// </summary>
            deleteuspecialcasedetail,
            /// <summary>
            /// 更改不适合处理票完成情况
            /// </summary>
            changeiscomplete,
            /// <summary>
            /// 删除重点品质问题记录
            /// </summary>
            deleteoqualitystrategy,
            /// <summary>
            /// 添加定期保养记录,用于补充
            /// </summary>
            addumackeep,

            updatestate,
            /// <summary>
            /// 删除翻新机性能检测记录
            /// </summary>
            deleteremachinetest,
            deleteufxcompletingcheck,
            deleteftradewarehousefee,
            createvin,
            createvin2,
            deletevin

        }

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string method = context.Request["ajaxmethod"];

            ajaxmethod xmethod = (ajaxmethod)Enum.Parse(typeof(ajaxmethod), method.Trim().ToLower());
            string temp="";
            switch (xmethod)
            {
                case ajaxmethod.deletemenu:
                    temp = DeleteMenu();
                    break;
                case ajaxmethod.deleterole:
                    temp = DeleteRole();
                    break;
                case ajaxmethod.deleteuser:
                    temp = DeleteUser();
                    break;
                case ajaxmethod.disableduser:
                    temp=disableduser();
                    break;
                case ajaxmethod.enableduser:
                    temp = enableduser();
                    break;
                case ajaxmethod.deletedaily:
                    temp = DeleteDaily();
                    break;
                case ajaxmethod.createvin:
                    temp = createvin();
                    break;
                case ajaxmethod.createvin2:
                    temp = createvin2();
                    break;
                case ajaxmethod.deleteocompletingcheck:
                    temp = deleteocompletingcheck();
                    break;
                case ajaxmethod.getotallyproject:
                    temp = getotallyproject();
                    break;
                case ajaxmethod.deleteoinspection:
                    temp = deleteoinspection();
                    break;
                case ajaxmethod.deleteoproject:
                    temp = DeleteOProject();
                    break;
                //用户资料系统
                case ajaxmethod.deleteuwarrantycard:
                    temp = DeleteUWarrantyCard();
                    break;
                case ajaxmethod.deleteureturnvisit:
                    temp = DeleteUReturnVisit();
                    break;
                case ajaxmethod.getuwarrantycardbyserialnumbert:
                    temp = getuwarrantycardbyserialnumbert();
                    break;
                case ajaxmethod.deleteu4008record:
                    temp = DeleteU4008Record();
                    break;
               
                case ajaxmethod.sendagentsmsgroup:
                    temp = SendAgentSMSGroup();
                    break;
                case ajaxmethod.sendcustomersmsgroup:
                    temp = SendCustomerSMSGroup();
                    break;
                case ajaxmethod.getutallysurvey:
                    temp = getUTallySurvey();
                    break;
                case ajaxmethod.deleteuqualityquestionnaire:
                    temp = deleteuqualityquestionnaire();
                    break;
                
                case ajaxmethod.deleteuagentmacstocklist:
                    temp = DeleteUAgentMacStockList();
                    break;
                case ajaxmethod.deleteuagentmacstockdetail:
                    temp = DeleteUAgentMacStockDetail();
                    break;
                case ajaxmethod.deleteumackeep:
                    temp = DeleteUMacKeep();
                    break;
               
                case ajaxmethod.syncuclaimdemage:
                    temp = SyncUClaimDemage();
                    break;
                case ajaxmethod.deleteuclaimdemagelist:
                    temp = DeleteUClaimDemageList();
                    break;
               
                case ajaxmethod.deleteocontrolticket:
                    temp = DeleteOControlTicket();
                    break;
               
               
                case ajaxmethod.deleteusupplerpart:
                    temp = deleteusupplerpart();
                    break;
                case ajaxmethod.changemysetting:
                    temp = changemysetting();
                    break;
                case ajaxmethod.deletekeepalarm:
                    temp = DeleteKeepAlarm();
                    break;
                case ajaxmethod.uclaimdemagecontrolupdatesupplerdetail:
                    temp = UClaimDemageControlUpdateSupplerDetail();
                    break;
                case ajaxmethod.uclaimdemagecontrolupdatefinaldetail:
                    temp = uclaimdemagecontrolupdatefinaldetail();
                    break;
                case ajaxmethod.deleteuclaimdemagecontrol:
                    temp = deleteuclaimdemagecontrol();
                    break;
               
               
                case ajaxmethod.deleteomailline:
                    temp = deleteomailline();
                    break;
               
                case ajaxmethod.deleteptoolingcharge:
                    temp = deleteptoolingcharge();
                    break;
                case ajaxmethod.deleteomarketqualification:
                    temp = deleteomarketqualification();
                    break;
                case ajaxmethod.deletemmarketitem:
                    temp = deletemmarketitem();
                    break;
                case ajaxmethod.deletespapersremind:
                    temp = deletespapersremind();
                    break;
                case ajaxmethod.deletemagentaddress:
                    temp = deletemagentaddress();
                    break;
                case ajaxmethod.deletexzkaoqin:
                    temp = deletexzkaoqin();
                    break;
                case ajaxmethod.checkenginenumber:
                    temp = checkenginenumber();
                    break;
                case ajaxmethod.deletejsdwffolder:
                    temp = deletejsdwffolder();
                    break;
                case ajaxmethod.deletejsdwf:
                    temp = deletejsdwf();
                    break;
                case ajaxmethod.deletejsdwfflowconfig:
                    temp = deletejsdwflowconfig();
                    break;
                case ajaxmethod.disabledjsdwfflowconfig:
                    temp = disabledjsdwfflowconfig();
                    break;
                case ajaxmethod.enabledjsdwfflowconfig:
                    temp = enabledjsdwfflowconfig();
                    break;
                case ajaxmethod.ocompletingcheckcheckuniquenum:
                    temp = ocompletingcheckcheckuniquenum();
                    break;
                case ajaxmethod.deletefxfinancelease:
                    temp = deletefxfinancelease();
                    break;
                case ajaxmethod.deletesareamanageragent:
                    temp = deletesareamanageragent();
                    break;
                case ajaxmethod.deleteftradereceivables:
                    temp = deleteftradereceivables();
                    break;
                case ajaxmethod.deleteftradeupkeep:
                    temp = deleteftradeupkeep();
                    break;

                case ajaxmethod.deleteftradecathering:
                    temp = deleteftradecathering();
                    break;
                case ajaxmethod.deleteftradecatheringall:
                    temp = deleteftradecatheringall();
                    break;
                case ajaxmethod.deleteounsuitableprod:
                    temp = deleteounsuitableprod();
                    break;
                case ajaxmethod.ftradereceivablescheckjihao:
                    temp = ftradereceivablescheckjihao();
                    break;
                case ajaxmethod.deletexztrain:
                    temp = deletexztrain();
                    break;
                case ajaxmethod.deleteyyshopment:
                    temp = deleteyyshopment();
                    break;
                case ajaxmethod.deleteftradeinvoice:
                    temp = deleteftradeinvoice();
                    break;
                case ajaxmethod.deletembaoyang:
                    temp = deletembaoyang();
                    break;
                case ajaxmethod.deleteuspecialcase:
                    temp = deleteuspecialcase();
                    break;
                case ajaxmethod.deleteuspecialcasedetail:
                    temp = deleteuspecialcasedetail();
                    break;
                case ajaxmethod.updatefanhuanlixistate:
                    temp = updatefanhuanlixistate();
                    break;
                case ajaxmethod.changeiscomplete:
                    temp = changeiscomplete();
                    break;
                case ajaxmethod.deleteoqualitystrategy:
                    temp = deleteoqualitystrategy();
                    break;
                case ajaxmethod.addumackeep:
                    temp = addumackeep();
                    break;
                case ajaxmethod.updatestate:
                    temp = UpdateState();
                    break;
                case ajaxmethod.deleteremachinetest:
                    temp = deleteremachinetest();
                    break;
                case ajaxmethod.deleteufxcompletingcheck:
                    temp = deleteufxcompletingcheck();
                    break;
                case ajaxmethod.deleteftradewarehousefee:
                    temp = deleteftradewarehousefee();
                    break;
                case ajaxmethod.deletevin:
                    temp = deletevin();
                    break;
            }

            context.Response.Write(temp);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        protected void AddDeleteLog(string DWZRef, object newobj)
        {
            SLogInfo obj = new SLogInfo();
            obj.LogType = "操作";
            obj.OpType = Permission.删除.ToString();
            obj.DWZRef = DWZRef;
            obj.RealName = OUserController.CurrentUser.RealName;
            obj.OpOldObj = newobj == null ? "" : newobj.SerializableToXml();
            SLogController.Add(obj);
        }

        #region 操作JSON
        public enum callbackType
        {
            forward,
            closeCurrent
        }
        /// <summary>
        /// 输入操作JOSN
        /// </summary>
        /// <param name="statusCode">200表示成功,300表示失败</param>
        /// <param name="message">操作提示消息</param>
        /// <param name="navTabId">服务器转回navTabId可以把那个navTab标记为reloadFlag=1, 下次切换到那个navTab时会重新载入内容</param>
        /// <param name="callbackType">callbackType如果是closeCurrent就会关闭当前tab,只有callbackType="forward"时需要forwardUrl值</param>
        /// <param name="forwardUrl">重新加的页面路径</param>
        /// <returns></returns>
        private string ResponseOpJson(string statusCode, string message, string navTabId, callbackType callbackType, string forwardUrl)
        {
           // string jsontemp = "{{\"statusCode\":\"200\",\"message\":\"操作成功\",\"navTabId\":\"\",\"callbackType\":\"forward\",\"forwardUrl\":\"sysbasic/omeunlist.aspx\"}}";
            string jsontemp = "{{\"statusCode\":\"{0}\",\"message\":\"{1}\",\"navTabId\":\"{2}\",\"callbackType\":\"{3}\",\"forwardUrl\":\"{4}\"}}";
            return string.Format(jsontemp, statusCode, message, navTabId, callbackType.ToString(), forwardUrl);
        }

        private string SuccessJson(string message, string navTabId, string forwardUrl)
        {
            return ResponseOpJson("200", message, navTabId, callbackType.forward, forwardUrl);
        }
        private string SuccessJson300(string message, string navTabId, string forwardUrl)
        {
            return ResponseOpJson("300", message, navTabId, callbackType.forward, forwardUrl);
        }

        private string SuccessJson(string message, string forwardUrl)
        {
            return ResponseOpJson("200", message, "", callbackType.forward, forwardUrl);
        }
        private string SuccessJson(string message)
        {
            return ResponseOpJson("200", message, "", callbackType.closeCurrent,"");
        }

        private string ErrorJson(string message, string navTabId, string forwardUrl)
        {
            return ResponseOpJson("300", message, navTabId, callbackType.forward, forwardUrl);
        }
        private string ErrorJson(string message, string forwardUrl)
        {
            return ResponseOpJson("300", message, "", callbackType.forward, forwardUrl);
        }
        private string ErrorJson(string message)
        {
            return ResponseOpJson("300", message, "", callbackType.closeCurrent, "");
        }
        #endregion

        #region 页面参数获取
        protected T GetRequestValue<T>(string name)
        {
            return HttpContext.Current.Request.GetRequestValue<T>(name);
        }

        protected T GetRequestValue<T>(string name, bool useDefValue, T defValue)
        {
            return HttpContext.Current.Request.GetRequestValue<T>(name, useDefValue, defValue);
        }
        protected T GetRequestValue<T>(string name, T defValue)
        {
            return HttpContext.Current.Request.GetRequestValue<T>(name, true, defValue);
        }
        #endregion
        #region sysbasic 系统管理模块相关
        private string DeleteMenu()
        {
            AddDeleteLog("OMeunList", GetRequestValue<int>("menuid"));

            bool r=  OMenuController.DeleteOMenuByMenuId(GetRequestValue<int>("menuid"));
            if (r)
                return SuccessJson("已成功删除相关菜单", "SysBasic/OMeunList.aspx");
            else
                return ErrorJson("删除失败","SysBasic/OMeunList.aspx");
        }

        private string DeleteRole()
        {
            AddDeleteLog("ORoleList", GetRequestValue<int>("roleid"));

            bool r = ORoleController.Delete(GetRequestValue<int>("roleid"));
            if (r)
                return SuccessJson("已成功删除角色", "SysBasic/ORoleList.aspx");
            else
                return ErrorJson("删除角色失败", "SysBasic/ORoleList.aspx");
           
        }
        private string DeleteUser()
        {
            AddDeleteLog("OUserList", GetRequestValue<int>("userid"));

            bool r = OUserController.Delete(GetRequestValue<int>("userid"));
            if (r)
                return SuccessJson("已成功删除用户", "SysBasic/OUserList.aspx");
            else
                return ErrorJson("删除用户失败", "SysBasic/OUserList.aspx");
        }

        private string disableduser()
        {
            int UserId = GetRequestValue<int>("userid");
            bool r = OUserController.ChangeState(UserId,0);
            if (r)
                return SuccessJson("已成功禁用用户", "SysBasic/OUserList.aspx");
            else
                return ErrorJson("禁用用户失败", "SysBasic/OUserList.aspx");
        }

        private string enableduser()
        {
            int UserId = GetRequestValue<int>("userid");
            bool r = OUserController.ChangeState(UserId, 1);
            if (r)
                return SuccessJson("已成功启用用户", "SysBasic/OUserList.aspx");
            else
                return ErrorJson("启用用户失败", "SysBasic/OUserList.aspx");
        }
        #endregion

        #region
        private string DeleteDaily()
        {
            int DailyId = GetRequestValue<int>("DailyId");

            AddDeleteLog("ODailyList", DailyId);

           
            bool r = ODailyController.Delete(DailyId);
            if (r)
                return SuccessJson("已成功删除", "MacModel/ODailyList.aspx");
            else
                return ErrorJson("删除失败", "MacModel/ODailyList.aspx");
        }
        #endregion

        private string deletejob()
        {
            string SerialNumber = GetRequestValue<string>("SerialNumber");

            AddDeleteLog("OJobList", SerialNumber);

            bool r = OJobController.Delete(SerialNumber);

            if (r )
                return SuccessJson("已成功删除", "OJobList", "MacModel/OJobListEasyUI.aspx");
            else
                return ErrorJson("删除失败<br/>" + r, "OJobList", "MacModel/OJobListEasyUI.aspx");

            //if (r)
            //    return SuccessJson("已成功删除", "MacModel/OJobList.aspx");
            //else
            //    return ErrorJson("删除失败", "MacModel/OJobList.aspx");
        }

        private string createvin()
        {
            string SerialNumber = GetRequestValue<string>("SerialNumber","");
            //string SCDATE= GetRequestValue<string>("SCDATE","");

            VinHistoryInfo obj = new VinHistoryInfo();
            obj= VINController.GetListBySer(SerialNumber);
            if (obj.ID > 0)
            {
                return ErrorJson("生成环保代码失败,此机号[" + SerialNumber + "]已生成过，如要再次生成请通知IT部", "OJobList", "MacModel/OJobListEasyUI.aspx");
            }

            // AddDeleteLog("OJobList", SerialNumber);
           // obj.SCDATE = SCDATE;//

            string createV = VINController.CreateVin(SerialNumber.Trim().ToUpper(), obj);

            if (createV !="")
            {
                return ErrorJson("生成失败,错误代码信息为:" + createV.ToString(), "OJobList", "MacModel/OJobListEasyUI.aspx");
            }


            int r = VINController.Add(obj);

            if (r>0)
                return SuccessJson300("已成功生成环保代码", "OJobList", "MacModel/OJobListEasyUI.aspx");
            else
                return ErrorJson("生成环保代码失败<br/>" + r, "OJobList", "MacModel/OJobListEasyUI.aspx");

       
        }
        private string createvin2()
        {
            string SerialNumber = GetRequestValue<string>("SerialNumber", "");
            string SCDATE= GetRequestValue<string>("SCDATE","");

            VinHistoryInfo obj = VINController.GetListBySer(SerialNumber);
            if (obj.ID <= 0)
            {
                return ErrorJson("更新环保代码失败,此机号[" + SerialNumber + "]未生成过VIN。", "OJobList", "MacModel/OJobListEasyUI.aspx");
            }
            OJobInfo _ojob = OJobController.GetBySerialNumber(SerialNumber.Trim().ToUpper());
            if (String.IsNullOrEmpty(_ojob.EngineNumber))
            {
                return ErrorJson("更新环保代码失败,此机号[" + SerialNumber + "]的发动机号未填写,请选填写再更新VIN", "OJobList", "MacModel/OJobListEasyUI.aspx");
            }
            if (String.IsNullOrEmpty(SCDATE))
            {
                return ErrorJson("更新环保代码失败,出厂日期未填写,请选填写再更新VIN", "OJobList", "MacModel/OJobListEasyUI.aspx");
            }

            obj.SCDATE = SCDATE;
            obj.FDJH = _ojob.EngineNumber;

            int r = VINController.Update(obj);

            if (r > 0)
                return SuccessJson300("已成功更新环保VIN出厂信息", "OJobList", "MacModel/OJobListEasyUI.aspx");
            else
                return ErrorJson("更新环保VIN出厂信息失败<br/>" + r, "OJobList", "MacModel/OJobListEasyUI.aspx");
        }
        private string deleteocompletingcheck()
        {
            int CCID = GetRequestValue<int>("CCID");

            AddDeleteLog("OCompletingCheckList", CCID);

            bool r = OCompletingCheckController.Delete(CCID);
            if (r)
                return SuccessJson("已成功删除", "MacModel/OCompletingCheckList.aspx");
            else
                return ErrorJson("删除失败", "MacModel/OCompletingCheckList.aspx");
        }
        private string getotallyproject()
        {
            string itemcode=GetRequestValue<string>("itemcode");
            OTallyprojectInfo obj = OInspectionController.OTallyproject_GetByItemCode(itemcode);
            return string.Format("{{\"ItemName\":\"{0}\",\"Standard\":\"{1}\"}}", obj.ItemName, obj.Standard);
        }

        private string deleteoinspection()
        {
            int ID = GetRequestValue<int>("ID");

            AddDeleteLog("OInspectionList", ID);

            bool r = OInspectionController.Delete(ID);
            if (r)
                return SuccessJson("已成功删除", "MacModel/OInspectionList.aspx");
            else
                return ErrorJson("删除失败", "MacModel/OInspectionList.aspx");
        }

        private string DeleteOProject()
        {
            int pid = GetRequestValue<int>("pid");

            AddDeleteLog("OProjectList", pid);

            bool r = OProjectController.Delete(pid);
            if (r)
                return SuccessJson("已成功删除", "MacModel/OProjectList.aspx");
            else
                return ErrorJson("删除失败", "MacModel/OProjectList.aspx");
        }

        private string DeleteOControlTicket()
        {
            string TNO = GetRequestValue<string>("TNO");

            AddDeleteLog("OControlTicketList", TNO);

            bool r = OControlTicketController.Delete(TNO);
            if (r)
                return SuccessJson("已成功删除", "MacModel/OControlTicketList.aspx");
            else
                return ErrorJson("删除失败", "MacModel/OControlTicketList.aspx");
        }
        #region 用户资料系统
        private string DeleteUWarrantyCard()
        {
            int uwcid = GetRequestValue<int>("uwcid");

            AddDeleteLog("UWarrantyCardList", uwcid);

            bool r = UWarrantyCardController.Delete(uwcid);
            if (r)
                return SuccessJson("已成功删除", "UserModel/UWarrantyCardList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/UWarrantyCardList.aspx");
        }

        private string DeleteUReturnVisit()
        {

            int uwcid = GetRequestValue<int>("uwcid");

            AddDeleteLog("UReturnVisitList", uwcid);

            bool r = UReturn500VisitController.Delete(uwcid);
            if (r)
                return SuccessJson("已成功删除", "UserModel/UReturnVisitList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/UReturnVisitList.aspx");
        }

        private string getuwarrantycardbyserialnumbert()
        {
            string sn = GetRequestValue<string>("SerialNumbert","");

          

            UWarrantyCardInfo obj=UWarrantyCardController.GetBySerialNumber(sn);
            if (obj == null)
                return "";
            string rjson = "{{\"CustomerName\":\"{0}\",\"IntoDate\":\"{1}\",\"CustomerTel\":\"{2}\",\"AgentName\":\"{3}\"}}";
            return string.Format(rjson, obj.CustomerName, obj.InputDate.ToString("yyyy-MM-dd"), obj.CustomerTel + "/" + obj.CustomerMobile, obj.AgentName);
        }

        private string DeleteU4008Record()
        {
            int U4RID = GetRequestValue<int>("U4RID", 0);

            AddDeleteLog("U4008RecordList", U4RID);

         

            bool r = U4008RecordController.Delete(U4RID);
            if (r)
                return SuccessJson("已成功删除", "UserModel/U4008RecordList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/U4008RecordList.aspx");
        }
       
        /// <summary>
        /// 获取机器点检完成调查表
        /// </summary>
        /// <returns></returns>
        private string getUTallySurvey()
        {
            var SerialNumbert = GetRequestValue<string>("SerialNumbert", "").ToUpper().Trim();
            UTallySurveyInfo obj= UTallySurveyController.GetBySerialNumber(SerialNumbert);
            if (obj == null)
            {
                UWarrantyCardInfo uwcobj = UWarrantyCardController.GetBySerialNumber(SerialNumbert);
                if (uwcobj == null)
                    return "";
                obj = new UTallySurveyInfo();
                obj.MachineType = uwcobj.MachineType;
                obj.AgentName = uwcobj.AgentName;
                obj.AgentTel = uwcobj.AgentTel;
                obj.AgentSvrPer = uwcobj.AgentSvrPer;
                obj.AgentSvrPerTel = uwcobj.AgentSvrPerTel;
            }

            string rjson = "{{\"MachineType\":\"{0}\",\"WorkAddress\":\"{1}\",\"WorkType\":\"{2}\",\"WorkTime\":\"{3}\",\"AgentName\":\"{4}\",\"AgentSvrPer\":\"{5}\",\"AgentSvrPerTel\":\"{6}\"}}";
            return string.Format(rjson, obj.MachineType, obj.WorkAddress, obj.WorkType, obj.WorkTime, obj.AgentName, obj.AgentSvrPer, obj.AgentSvrPerTel);
        }

        private string deleteuqualityquestionnaire()
        {
            int UQQID = GetRequestValue<int>("UQQID");

            AddDeleteLog("UQualityQuestionnaireList", UQQID);

            bool r = UQualityQuestionnaireController.Delete(UQQID);
            if (r)
                return SuccessJson("已成功删除", "UserModel/UQualityQuestionnaireList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/UQualityQuestionnaireList.aspx");
        }

        
        #endregion
         #region 短信发送
        /*
       
        /// <summary>
        /// 发送单条生日短信.2011-11-12已废除
        /// </summary>
        /// <returns></returns>
        private string sendsingbirthday()
        {
            string mobile = GetRequestValue<string>("mobile");
            int UWCID = GetRequestValue<int>("UWCID");

            string birthdaysmstempletekey = ConfigurationManager.AppSettings["birthdaysmstempletekey"];
            if (birthdaysmstempletekey.IsEmptyOrNull())
                return ErrorJson("生日短信发送失败[未找到生日短信模板相应配置]", "UserModel/UBirthdayAlarmList.aspx");

            string smsmessage = USMSTempleteController.GetSMSContent(UWCID, birthdaysmstempletekey);

            string result = SMSController.SendSing(mobile, smsmessage, "");
            if (string.IsNullOrEmpty(result))
            {
                UBirthdayAlarmController.UpdateSendSMS(UWCID);
                return SuccessJson("已成功发送", "UserModel/UBirthdayAlarmList.aspx"); ;
            }
            else
                return ErrorJson("生日短信发送失败", "UserModel/UBirthdayAlarmList.aspx");
        }

        /// <summary>
        /// 批量发送生日短信 .2011-11-12已废除
        /// </summary>
        /// <returns></returns>
        private string PersonalitySendBirthday()
        {
            string birthdaysmstempletekey = ConfigurationManager.AppSettings["birthdaysmstempletekey"];
            if (birthdaysmstempletekey.IsEmptyOrNull())
                return ErrorJson("生日短信发送失败[未找到生日短信模板相应配置]", "UserModel/UBirthdayAlarmList.aspx");

            string[] UWCIDS = GetRequestValue<string>("UWCIDS").Split(new char[] { ',' });
            string mobiles = "";
            string smscontents = "";
            int i = 0;
            foreach (string uwcid in UWCIDS)
            {
                if (uwcid.IsEmptyOrNull())
                    continue;
                UWarrantyCardExInfo obj = UWarrantyCardExController.GetByUWCID(Convert.ToInt32(uwcid));
                if (obj == null)
                    continue;
                mobiles += i == 0 ? obj.CustomerMobile : "," + obj.CustomerMobile;
                string smsmessage = USMSTempleteController.UWarrantyCardReplaceTagSys(obj, birthdaysmstempletekey);
                smsmessage = HttpUtility.HtmlEncode(smsmessage);

                smscontents += i == 0 ? smsmessage : "," + smsmessage;
                i++;
            }
            string result = SMSController.PersonalitySend(mobiles, smscontents, "");
            if (string.IsNullOrEmpty(result))
            {

                foreach (string uwcid in UWCIDS)
                {
                    if (uwcid.IsEmptyOrNull())
                        continue;
                    UBirthdayAlarmController.UpdateSendSMS(Convert.ToInt32(uwcid));
                }
                return SuccessJson("已成功发送", "UserModel/UBirthdayAlarmList.aspx"); ;
            }
            else
                return ErrorJson("生日短信发送失败" + result, "UserModel/UBirthdayAlarmList.aspx");
        }
        
        /// <summary>
        /// 批量发送保养警报短信 .2011-11-12已废除
        /// </summary>
        /// <returns></returns>
        private string PersonalitySendKeepAlarm()
        {
            string[] UMKAIDS = GetRequestValue<string>("UMKAIDS").Split(new char[] { ',' });
            string mobiles = "";
            string smscontents = "";
            int i = 0;
            DataTable umdt = UMacKeepController.UMacKeepAlarm_GetALL();
            foreach (string uwcid in UMKAIDS)
            {
                if (uwcid.IsEmptyOrNull())
                    continue;

                DataRow dr= umdt.Select("UMKAID=" + uwcid)[0];

                mobiles += i == 0 ? dr["CustomerMobile"].ToString() : "," + dr["CustomerMobile"].ToString();
                string smsmessage = dr["AlarmSMSContent"].ToString();
                smsmessage = HttpUtility.HtmlEncode(smsmessage);

                smscontents += i == 0 ? smsmessage : "," + smsmessage;
                i++;
            }
            string result = SMSController.PersonalitySend(mobiles, smscontents, "");
            if (string.IsNullOrEmpty(result))
            {

                foreach (string uwcid in UMKAIDS)
                {
                    if (uwcid.IsEmptyOrNull())
                        continue;
                    UMacKeepController.UMacKeepAlarm_UpdateSendSMS(Convert.ToInt32(uwcid));
                }
                return SuccessJson("已成功发送", "UserModel/UMacKeepAlarmList.aspx"); ;
            }
            else
                return ErrorJson("短信发送失败" + result, "UserModel/UMacKeepAlarmList.aspx");
        }
        /// <summary>
        /// 发送单条保养警报短信 .2011-11-12已废除
        /// </summary>
        /// <returns></returns>
        private string sendsingkeepalarm()
        {
            
            int UWCID = GetRequestValue<int>("UMKAID");

            //string birthdaysmstempletekey = ConfigurationManager.AppSettings["birthdaysmstempletekey"];
            //if (birthdaysmstempletekey.IsEmptyOrNull())
            //    return ErrorJson("生日短信发送失败[未找到生日短信模板相应配置]", "UserModel/UBirthdayAlarmList.aspx");
            DataTable umdt = UMacKeepController.UMacKeepAlarm_GetALL();
            DataRow dr = umdt.Select("UMKAID=" + UWCID.ToString())[0];
            string smsmessage = dr["AlarmSMSContent"].ToString();
            string mobile = dr["CustomerMobile"].ToString();
            string result = SMSController.SendSing(mobile, smsmessage, "");
            if (string.IsNullOrEmpty(result))
            {
                UMacKeepController.UMacKeepAlarm_UpdateSendSMS(UWCID);
                return SuccessJson("已成功发送", "UserModel/UMacKeepAlarmList.aspx"); ;
            }
            else
                return ErrorJson("发送失败", "UserModel/UBirthdayAlarmList.aspx");
        }
         *  * */
        /// <summary>
        /// 代理商短信群发
        /// </summary>
        /// <returns></returns>
        private string SendAgentSMSGroup()
        {
            string AgentNames = GetRequestValue<string>("AgentName", "");
            string smskey = GetRequestValue<string>("smskey", "");

            SMSProccessController.Add("通信录代理商短信群发", AgentNames, smskey);
            return SuccessJson("已成功发送", "UserModel/UWarrantyCardExList.aspx");

        }
        /// <summary>
        /// 通信录多选批量发送
        /// </summary>
        /// <returns></returns>
        private string SendCustomerSMSGroup()
        {
            string uwcids = GetRequestValue<string>("uwcids", "");
            string smskey = GetRequestValue<string>("smskey", "");
            SMSProccessController.Add("通信录多选批量发送", uwcids, smskey);
            return SuccessJson("已成功发送", "UserModel/UWarrantyCardExList.aspx");
           
        }
        #endregion

        private string DeleteUAgentMacStockList()
        {
            int UASID = GetRequestValue<int>("UASID");

            AddDeleteLog("UAgentMacStockList", UASID);

            bool r = UAgentMacStockController.Delete(UASID);
            if (r)
                return SuccessJson("已成功删除", "UserModel/UAgentMacStockList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/UAgentMacStockList.aspx");
        }

        private string DeleteUAgentMacStockDetail()
        {
            int UASDID = GetRequestValue<int>("UASDID");

            AddDeleteLog("UAgentMacStockList", UASDID);


            bool r = UAgentMacStockController.UAgentMacStockDetail_Delete(UASDID);
            if (r)
                return SuccessJson("已成功删除","", "");
            else
                return ErrorJson("删除失败", "","");
        }
        private string DeleteUMacKeep()
        {
            string SerialNumber = GetRequestValue<string>("SerialNumber","");

            AddDeleteLog("UMacKeepList", SerialNumber);

            bool r = UMacKeepController.Delete(SerialNumber);
            if (r)
                return SuccessJson("已成功删除", "UserModel/UMacKeepList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/UMacKeepList.aspx");
        }
        private string DeleteUClaimDemageList()
        {
            int id = GetRequestValue<int>("id",0);

            AddDeleteLog("UClaimDemageList", id);


            bool r = UClaimDemageController.Delete(id);
            if (r)
                return SuccessJson("已成功删除", "UserModel/UClaimDemageList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/UClaimDemageList.aspx");
        }
        private string deleteusupplerpart()
        {
            string id = GetRequestValue<string>("itemcode", "");

            AddDeleteLog("USupplerPartList", id);

            bool r = USupplerPartController.Delete(id);
            if (r)
                return SuccessJson("已成功删除", "UserModel/USupplerPartList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/USupplerPartList.aspx");
        }

        /// <summary>
        /// 批量标记已发送保养警报短信
        /// </summary>
        /// <returns></returns>
        private string DeleteKeepAlarm()
        {
            string[] UMKAIDS = GetRequestValue<string>("UMKAIDS").Split(new char[] { ',' });

            AddDeleteLog("UMacKeepAlarmList", UMKAIDS);

            try
            {

                foreach (string uwcid in UMKAIDS)
                {
                    if (uwcid.IsEmptyOrNull())
                        continue;
                    UMacKeepController.UMacKeepAlarm_UpdateSendSMS(Convert.ToInt32(uwcid));
                }
                return SuccessJson("删除成功", "UserModel/UMacKeepAlarmList.aspx"); ;
            }
            catch
            {
                return ErrorJson("删除失败", "UserModel/UMacKeepAlarmList.aspx");
            }
        }
        
        #region 同步相关
        private string SyncUClaimDemage()
        {
           return SyncSAPController.SyncUClaimDemage()?"":"索赔发货记录同步失败"+DateTime.Now.ToString();
        }
        #endregion

        #region 自动完成相关
        /// <summary>
        /// 查询关键字
        /// </summary>
        protected string key
        {
            get
            {
                return GetRequestValue<string>("q", true, "");
            }
        }
        /// <summary>
        /// 获取记录的前几条
        /// </summary>
        protected int toprow
        {
            get
            {

                return GetRequestValue<int>("limit", true, 20);
            }
        }
         
        #endregion
        /// <summary>
        /// 更新我的个性化设置
        /// </summary>
        /// <returns></returns>
        private string changemysetting()
        {
            string[] mysettingkey = new string[] { "AutoHideMenu", "AutoPoppingAlarm", "MyNumPerPage" };
            string mysettingvalue = "";
            foreach (string key in mysettingkey)
            {
                mysettingvalue += (string.IsNullOrEmpty(mysettingvalue)?"":",")+ key + "|" + GetRequestValue<string>(key, "");
            }

            OUserController.ChangeMySetting(OUserController.CurrentUser.UserId, mysettingvalue);
            return "";
        }


        private string UClaimDemageControlUpdateSupplerDetail()
        {
            try
            {
                UClaimDemageControlDetailInfo obj = HttpContext.Current.Request.SerializableObject<UClaimDemageControlDetailInfo>();

                //if (obj.SuoPeiNum.IsEmptyOrNull())
                //{
                //    obj.ControlDetailID = -1;
                //}
                bool r = UClaimDemageControlController.UpdateSupplerDetail(obj);

                return "";
            }
            catch(ExecutionEngineException ee)
            {
                return ee.Message;
            }
            
        }

        private string uclaimdemagecontrolupdatefinaldetail()
        {
            try
            {
                UClaimDemageControlDetailInfo obj = HttpContext.Current.Request.SerializableObject<UClaimDemageControlDetailInfo>();
                if (obj.SuoPeiNum.IsEmptyOrNull())
                {
                    obj.ControlDetailID = -1;
                }
                bool r = UClaimDemageControlController.UpdateFinalDetail(obj);

                return "";
            }
            catch (ExecutionEngineException ee)
            {
                return ee.Message;
            }
        }

        private string deleteuclaimdemagecontrol()
        {
            string ClaimsNumber = GetRequestValue<string>("ClaimsNumber", "");

            AddDeleteLog("UClaimDemageControlList", ClaimsNumber);


            bool r = UClaimDemageControlController.Delete(ClaimsNumber);
            if (r)
                return SuccessJson("已成功删除", "UserModel/UClaimDemageControlList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/UClaimDemageControlList.aspx");
        }

        private string deleteomailline()
        {
            int MLID = GetRequestValue<int>("MLID", 0);

            AddDeleteLog("OMailLineList", MLID);

            bool r = OMailLineController.DeleteOMailLine(MLID);
            if (r)
                return SuccessJson("已成功删除", "MacModel/OMailLineList.aspx");
            else
                return ErrorJson("删除失败", "MacModel/OMailLineList.aspx");
        }

       

        private string deleteptoolingcharge()
        {
            int ID = GetRequestValue<int>("ID", 0);

            AddDeleteLog("PToolingChargeList", ID);

            bool r = PToolingChargeController.Delete(ID);
            if (r)
                return SuccessJson("已成功删除", "ProdModel/PToolingChargeList.aspx");
            else
                return ErrorJson("删除失败", "ProdModel/PToolingChargeList.aspx");
        }

        private string deleteomarketqualification()
        {
            int MQID = GetRequestValue<int>("MQID", 0);

            AddDeleteLog("OMarketQualificationList", MQID);

            bool r = OMarketQualificationController.Delete(MQID);
            if (r)
                return SuccessJson("已成功删除", "MacModel/OMarketQualificationList.aspx");
            else
                return ErrorJson("删除失败", "MacModel/OMarketQualificationList.aspx");
        }

        private string deletemmarketitem()
        {
            int MMID = GetRequestValue<int>("MMID", 0);

            AddDeleteLog("MMarketitemList", MMID);

            bool r = MMarketItemController.Delete(MMID);
            if (r)
                return SuccessJson("已成功删除", "MarketModel/MMarketitemList.aspx");
            else
                return ErrorJson("删除失败", "MarketModel/MMarketitemList.aspx");
        }

        private string deletespapersremind()
        {
            int MMID = GetRequestValue<int>("id", 0);

            AddDeleteLog("SPapersRemindList", MMID);

            bool r = SPapersRemindController.Delete(MMID);
            if (r)
                return SuccessJson("已成功删除", "PublicModel/SPapersRemindList.aspx");
            else
                return ErrorJson("删除失败", "PublicModel/SPapersRemindList.aspx");
        }

        private string deletemagentaddress()
        {
            int MMID = GetRequestValue<int>("MAAID", 0);

            AddDeleteLog("MMarketitemList", MMID);

            bool r = MAgentAddressController.Delete(MMID);
            if (r)
                return SuccessJson("已成功删除", "MAgentAddressList", "MarketModel/MAgentAddressList.aspx?CardCode=" + GetRequestValue<string>("CardCode",""));
            else
                return ErrorJson("删除失败", "MAgentAddressList", "MarketModel/MAgentAddressList.aspx?CardCode=" + GetRequestValue<string>("CardCode", ""));
        }

        private string deletexzkaoqin()
        {
            int KQID = GetRequestValue<int>("KQID", 0);

            AddDeleteLog("XZKaoQinList", KQID);

            bool r = XZKaoQinController.Delete(KQID);
            if (r)
                return SuccessJson("已成功删除", "XZKaoQinList", "XZModel/XZKaoQinList.aspx");
            else
                return ErrorJson("删除失败", "XZKaoQinList", "XZModel/XZKaoQinList.aspx");
        }

        private string deletejsdwffolder()
        {
            int FolderID = GetRequestValue<int>("FolderID", 0);
            AddDeleteLog("JSDWFFolderList", FolderID);

            int r = JSDWFFolderController.Delete(FolderID);
            if (r == -1)
            {
                return ErrorJson("删除失败,此目录下的还有其它文件或文件夹,无法进行删除，请联系IT部", "JSDWFFolderList", "JSDWF/JSDWFFolderList.aspx");
            }
            if (r>0)
                return SuccessJson("已成功删除", "JSDWFFolderList", "JSDWF/JSDWFFolderList.aspx");
            else
                return ErrorJson("删除失败", "JSDWFFolderList", "JSDWF/JSDWFFolderList.aspx");
        }

        private string deletejsdwf()
        {
            string dwfid = GetRequestValue<string>("dwfid", "");
            AddDeleteLog("JSDWFList", dwfid);
            /*
             文件删除
             */
            JSDWFInfo dwfObj=JSDWFController.GetByDWFID(new Guid(dwfid));
            JSDWFFolderInfo folderObj=JSDWFFolderController.GetByFolderID(dwfObj.FolderID);
            string filepath=folderObj.FolderPath+"/"+dwfObj.FileName;
            try
            {
                File.Delete(HttpContext.Current.Request.PhysicalApplicationPath + filepath);

                JSDWFController.Delete(new Guid(dwfid));

                return SuccessJson("已成功删除", "JSDWFList", "JSDWF/JSDWFList.aspx"); 
            }
            catch
            {
                return ErrorJson("删除失败", "JSDWFList", "JSDWF/JSDWFList.aspx"); 
                
            }
        }

        private string deletejsdwflowconfig()
        {
            int FlowId = GetRequestValue<int>("FlowId", 0);
            int AdtlvlID = GetRequestValue<int>("AdtlvlID", 0);
            AddDeleteLog("JSDWFFlowConfigList", FlowId);

            bool r = JSDWFFlowConfigController.Delete(FlowId, AdtlvlID);
            if (r)
                return SuccessJson("已成功删除", "JSDWFFlowConfigList", "JSDWF/JSDWFFlowConfigList.aspx");
            else
                return ErrorJson("删除失败", "JSDWFFlowConfigList", "JSDWF/JSDWFFlowConfigList.aspx");
        }

        private string disabledjsdwfflowconfig()
        {
            int FlowId = GetRequestValue<int>("FlowId", 0);

           // AddDeleteLog("JSDWFFlowConfigList", FlowId);
            int AdtlvlID = GetRequestValue<int>("AdtlvlID", 0);
            JSDWFFlowConfigInfo obj = JSDWFFlowConfigController.GetByFlowId(FlowId, AdtlvlID);
            obj.State = false;

            bool r = JSDWFFlowConfigController.Update(obj);
            if (r)
                return SuccessJson("已成功禁用", "JSDWFFlowConfigList", "JSDWF/JSDWFFlowConfigList.aspx");
            else
                return ErrorJson("禁用失败", "JSDWFFlowConfigList", "JSDWF/JSDWFFlowConfigList.aspx");
        }

        private string enabledjsdwfflowconfig()
        {
            int FlowId = GetRequestValue<int>("FlowId", 0);

            // AddDeleteLog("JSDWFFlowConfigList", FlowId);
            int AdtlvlID = GetRequestValue<int>("AdtlvlID", 0);
            JSDWFFlowConfigInfo obj = JSDWFFlowConfigController.GetByFlowId(FlowId, AdtlvlID);
            obj.State = true;

            bool r = JSDWFFlowConfigController.Update(obj);
            if (r)
                return SuccessJson("已成功启用", "JSDWFFlowConfigList", "JSDWF/JSDWFFlowConfigList.aspx");
            else
                return ErrorJson("启用失败", "JSDWFFlowConfigList", "JSDWF/JSDWFFlowConfigList.aspx");
        }

        private string checkenginenumber()
        {
            string EngineNumber = GetRequestValue<string>("EngineNumber","");
            string SerialNumber = GetRequestValue<string>("SerialNumber", "");
            int vtype = GetRequestValue<int>("vtype", 0);

            return OJobController.CheckEngineNumber(SerialNumber, EngineNumber, vtype);
        }

        private string ocompletingcheckcheckuniquenum()
        {
            string ColumnName = GetRequestValue<string>("cn", "");
            string ColumnValue = GetRequestValue<string>(ColumnName, "");

            int result = OCompletingCheckController.OCompletingCheck_GetCheckUniqueNum(ColumnName, ColumnValue);
            return result > 0 ? "1" : "0";
        }

        private string deletefxfinancelease()
        {
            int FnncLsId = GetRequestValue<int>("FnncLsId", 0);

            AddDeleteLog("FXFinanceLeaseMasterList", FnncLsId);

            bool r = FXFinanceLeaseController.Delete(FnncLsId);
            if (r)
                return SuccessJson("已成功删除", "FXFinanceLeaseMasterList", "FXModel/FXFinanceLeaseMasterList.aspx");
            else
                return ErrorJson("删除失败", "FXFinanceLeaseMasterList", "FXModel/FXFinanceLeaseMasterList.aspx");
        }

        private string deletesareamanageragent()
        {
            int id = GetRequestValue<int>("id", 0);

            AddDeleteLog("SAreaManagerMasterList", id);

            bool r = SAreaManagerAgentController.Delete(id);
            if (r)
                return SuccessJson("已成功删除", "SAreaManagerMasterList", "FXModel/SAreaManagerMasterList.aspx");
            else
                return ErrorJson("删除失败", "SAreaManagerMasterList", "FXModel/SAreaManagerMasterList.aspx");
        }

        #region 应收帐款
        private string deleteftradereceivables()
        {
            int FTradeID = GetRequestValue<int>("FTradeID", 0);

            AddDeleteLog("FTradeReceivablesListEasyUI", FTradeID);

            string r = FTradeReceivablesController.Delete(FTradeID);
            if (r=="")
                return SuccessJson("已成功删除", "FTradeReceivablesListEasyUI", "FTradeModel/FTradeReceivablesListEasyUI.aspx");
            else
                return ErrorJson("删除失败<br/>"+r, "FTradeReceivablesListEasyUI", "FTradeModel/FTradeReceivablesListEasyUI.aspx");
        }

        private string updatefanhuanlixistate()
        {
            int FTradeID = GetRequestValue<int>("FTradeID", 0);
            string FanHuanLiXiState = GetRequestValue<string>("FanHuanLiXiState", "正常(已结算)");
            bool r = FTradeReceivablesController.UpdateFanHuanLiXiState(FTradeID, FanHuanLiXiState);

            return "";
            //if (r)
            //    return SuccessJson("已成功删除", "FTradeUpKeepList", "FTradeModel/FTradeUpKeepList.aspx?FTradeID=" + FTradeID.ToString());
            //else
            //    return ErrorJson("删除失败<br/>", "FTradeUpKeepList", "FTradeModel/FTradeUpKeepList.aspx?FTradeID=" + FTradeID.ToString());

        }
        private string deleteftradeupkeep()
        {
            int id = GetRequestValue<int>("id", 0);
            int FTradeID = GetRequestValue<int>("FTradeID", 0);

            AddDeleteLog("FTradeUpKeepList", id);

            bool r = FTradeUpKeepController.Delete(id);
            if (r)
                return SuccessJson("已成功删除", "FTradeUpKeepList", "FTradeModel/FTradeUpKeepList.aspx?FTradeID=" + FTradeID.ToString());
            else
                return ErrorJson("删除失败<br/>", "FTradeUpKeepList", "FTradeModel/FTradeUpKeepList.aspx?FTradeID=" + FTradeID.ToString());
        }
        //取消
        private string deleteftradecathering()
        {
            try
            {
                int FCatheringId = GetRequestValue<int>("FCatheringId", 0);
                string remark = GetRequestValue<string>("remark", "");
                decimal DongJieJinE = GetRequestValue<decimal>("DongJieJinE", 0m);
                AddDeleteLog("FTradeCatheringListEasyUI", FCatheringId);

                string r = FTradeCatheringController.Delete(FCatheringId, remark, DongJieJinE);
                if (r == "")
                    return SuccessJson("已成功取消", "FTradeCatheringListEasyUI", "FTradeModel/FTradeCatheringListEasyUI.aspx");
                else
                    return ErrorJson("取消失败<br/>" + r, "FTradeCatheringListEasyUI", "FTradeModel/FTradeCatheringListEasyUI.aspx");
            }
            catch(Exception EXC)
            {
                return ErrorJson("取消失败<br/>" + EXC.Message, "FTradeCatheringListEasyUI", "FTradeModel/FTradeCatheringListEasyUI.aspx");
            }
        }
        //删除
        private string deleteftradecatheringall()
        {
            int FCatheringId = GetRequestValue<int>("FCatheringId", 0);

            string r = FTradeCatheringController.DeleteAll(FCatheringId);
            if (r == "")
                return SuccessJson("已成功删除", "FTradeCatheringListEasyUI", "FTradeModel/FTradeCatheringListEasyUI.aspx");
            else
                return ErrorJson("删除失败<br/>" + r, "FTradeCatheringListEasyUI", "FTradeModel/FTradeCatheringListEasyUI.aspx");
        }

        private string deleteounsuitableprod()
        {
            int UnsuitabledID = GetRequestValue<int>("UnsuitabledID", 0);

            AddDeleteLog("OUnsuitableProdList", UnsuitabledID);

            Boolean r = OUnsuitableProdController.Delete(UnsuitabledID);
            if (r )
                return SuccessJson("已成功删除", "OUnsuitableProdList", "MacModel/OUnsuitableProdListEasyUi.aspx");
            else
                return ErrorJson("删除失败", "OUnsuitableProdList", "MacModel/OUnsuitableProdListEasyUi.aspx");
        }
        
        #endregion


        private string ftradereceivablescheckjihao()
        {
            string JiHao = GetRequestValue<string>("JiHao", "");
            int FTradeID = GetRequestValue<int>("FTradeID", 0);

            return FTradeReceivablesController.CheckJiHao(JiHao, FTradeID);
        }

        private string deletexztrain()
        {
            int TrainId = GetRequestValue<int>("TrainId", 0);
            Boolean r = XZJobTrainController.DeleteXZTrainList(TrainId);
            if (r)
                return SuccessJson("已成功删除", "XZTrainList", "XZModel/XZTrainList.aspx");
            else
                return ErrorJson("删除失败", "XZTrainList", "XZModel/XZTrainList.aspx");
        }

        private string deleteyyshopment()
        {
            int ShipmentID = GetRequestValue<int>("ShipmentID", 0);

           // AddDeleteLog("FTradeUpKeepList", FCatheringId);

            bool r = YYShipmentController.Delete(ShipmentID);
            if (r )
                return SuccessJson("已成功删除", "YYShipmentListEasyUI", "YYModel/YYShipmentListEasyUI.aspx");
            else
                return ErrorJson("删除失败<br/>", "YYShipmentListEasyUI", "YYModel/YYShipmentListEasyUI.aspx");
        }

        private string deleteftradeinvoice()
        {
            int id = GetRequestValue<int>("id", 0);
            int FTradeID = GetRequestValue<int>("FTradeID", 0);

            AddDeleteLog("FTradeUpKeepList", id);

            bool r = FTradeInvoiceController.Delete(id);
            if (r)
                return SuccessJson("已成功删除", "FTradeInvoiceList", "FTradeModel/FTradeInvoiceList.aspx?FTradeID=" + FTradeID.ToString());
            else
                return ErrorJson("删除失败<br/>", "FTradeInvoiceList", "FTradeModel/FTradeInvoiceList.aspx?FTradeID=" + FTradeID.ToString());
        }

        private string deletembaoyang()
        {
            int id = GetRequestValue<int>("id", 0);

            bool r = MBaoYangController.Delete(id);
            if (r)
                return SuccessJson("已成功删除", "MBaoYangListEasyUI", "MarketModel/MBaoYangListEasyUI.aspx");
            else
                return ErrorJson("删除失败<br/>", "MBaoYangListEasyUI", "MarketModel/MBaoYangListEasyUI.aspx");
        }


        private string deleteuspecialcase()
        {
            int id = GetRequestValue<int>("scid", 0);

            bool r = USpecialCaseController.Delete(id);
            if (r)
                return SuccessJson("已成功删除", "USpecialCaseList", "UserModel/USpecialCaseList.aspx");
            else
                return ErrorJson("删除失败<br/>", "USpecialCaseList", "UserModel/USpecialCaseList.aspx");
        }

        private string deleteuspecialcasedetail()
        {
            int id = GetRequestValue<int>("id", 0);

            bool r = USpecialCaseController.USpecialCaseDetail_Delete(id);
            if (r)
                return SuccessJson("已成功删除", "USpecialCaseDetailList", "UserModel/USpecialCaseDetailList.aspx");
            else
                return ErrorJson("删除失败<br/>", "USpecialCaseDetailList", "UserModel/USpecialCaseDetailList.aspx");
        }

        private string changeiscomplete()
        {
            int UnsuitabledID = GetRequestValue<int>("UnsuitabledID", 0);
            string IsComplete = GetRequestValue<string>("IsComplete", "");

            bool r = OUnsuitableProdController.UpdateIsComplete(UnsuitabledID, IsComplete);

            return "";
        }
        private string deleteoqualitystrategy()
        {
            int qsid = GetRequestValue<int>("qsid", 0);
            bool r = OQualityStrategyController.Delete(qsid);

            return "";
        }

        private string addumackeep()
        {
            int UWCID = GetRequestValue<int>("UWCID", 0);

            UWarrantyCardInfo obj = UWarrantyCardController.GetByUWCID(UWCID);

            UMacKeepInfo UKObj = new UMacKeepInfo();
            UKObj.SerialNumber = obj.SerialNumber.ToUpper().Trim();
            UKObj.IsWarrantyCard = true;
            UKObj.IntoDate = obj.IntoDate;
            UKObj.IntoHours = obj.IntoHours;
            UKObj.CustomerName = obj.CustomerName;
            UKObj.CustomerMobile = obj.CustomerMobile;
            UKObj.CustomerAddress = obj.CustomerAddress;
            UKObj.AgentName = obj.AgentName;
            UKObj.AgentTel = obj.AgentTel;
            UKObj.Remark = "";
            UKObj.FirstCostDate = "";
            UKObj.FirstCost = 0m;
            UKObj.SecondCostDate = "";
            UKObj.SecondCost = 0m;
            UKObj.CostRemark = "";
            int r=  UMacKeepController.Add(UKObj);
            if (r>0)
                return SuccessJson("已成功添加定期保养", "UWarrantyCardAgentList", "SvrMgr/UWarrantyCardAgentList.aspx");
            else
                return ErrorJson("添加定期保养失败<br/>", "UWarrantyCardAgentList", "SvrMgr/UWarrantyCardAgentList.aspx");
        }

        private string UpdateState()
        {
            int UWCID = GetRequestValue<int>("UWCID", 0);
            string VisitType = GetRequestValue<string>("VisitType", "");
            bool r = UOneMonthAlarmController.UpdateState(UWCID, VisitType);

            return SuccessJson("成功删除,需手工刷新列表", "default_AlarmList", "usermodel/AlarmList.aspx");
        }


        private string deleteremachinetest()
        {
            int testid = GetRequestValue<int>("testid", 0);

            bool r = ReMachineTestController.Delete(testid);
            if (r)
                return SuccessJson("已成功删除", "ReMachineTestList", "UserModel/ReMachineTestList.aspx");
            else
                return ErrorJson("删除失败<br/>", "ReMachineTestList", "UserModel/ReMachineTestList.aspx");
        }

        private string deleteufxcompletingcheck()
        {
            int CCID = GetRequestValue<int>("CCID");

           // AddDeleteLog("OCompletingCheckList", CCID);

            bool r = UFXCompletingCheckController.Delete(CCID);
            if (r)
                return SuccessJson("已成功删除", "UserModel/UFXCompletingCheckList.aspx");
            else
                return ErrorJson("删除失败", "UserModel/UFXCompletingCheckList.aspx");
        }

        private string deleteftradewarehousefee()
        {
            int id = GetRequestValue<int>("id", 0);

            bool r = FTradeWarehouseFeeController.Delete(id);
            if (r)
                return SuccessJson("已成功删除", "FTradeWarehouseFeeList", "FTradeModel/FTradeWarehouseFeeList.aspx");
            else
                return ErrorJson("删除失败<br/>", "FTradeWarehouseFeeList", "FTradeModel/FTradeWarehouseFeeList.aspx");
        }
        private string deletevin()
        {
            int id = GetRequestValue<int>("id", 0);

            bool r = VINController.Delete(id);
            if (r)
                return SuccessJson("已成功删除", "VINList", "MacModel/VINList.aspx");
            else
                return ErrorJson("删除失败<br/>", "VINList", "MacModel/VINList.aspx");
        }
        

    }
}